<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>添加角色</title>
  <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
</body>
<div class="layui-container" style="margin-top: 30px;">
  <form class="layui-form">
    <div class="layui-form-item">
      <label class="layui-form-label">排序</label>
      <div class="layui-input-block">
        <input type="text" name="sort" value="0" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">菜单类型</label>
      <div class="layui-input-block">
        <input type="radio" name="type" value="2" checked title="店铺菜单">
        <input type="radio" name="type" value="1" title="系统菜单">
      </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选择上级菜单</label>
        <div class="layui-input-block">
          <select name="parent_id" lay-verify="required" id="parent-id">
            <option value="0">顶级菜单</option>
            {foreach $menuOption as $vo}
            <option value="{$vo.id}">{$vo.title}</option>
            {/foreach}
          </select>
        </div>
      </div>
    <div class="layui-form-item">
        <label class="layui-form-label">菜单名称</label>
        <div class="layui-input-block">
          <input type="text" name="title" required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
        </div>
      </div>
    <div class="layui-form-item">
      <label class="layui-form-label">url地址</label>
      <div class="layui-input-inline">
        <input type="text" name="url" value="#" required lay-verify="required" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">权限节点</label>
      <div class="layui-input-inline">
        <input type="text" name="node" autocomplete="off" class="layui-input">
      </div>
      <div class="layui-form-mid layui-word-aux layui-font-red">权限节点 示例 如admin@index@index</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">参数</label>
        <div class="layui-input-inline">
          <input type="text" name="param" autocomplete="off" class="layui-input">
        </div>
      </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否左侧显示</label>
        <div class="layui-input-block">
          <select name="display" lay-verify="required">
            <option value="1">是</option>
            <option value="0">否</option>  
          </select>
        </div>
      </div>
    <div class="layui-form-item">
      <label class="layui-form-label">状态</label>
      <div class="layui-input-block">
        <input type="radio" name="status" value="1"  checked title="启用">
        <input type="radio" name="status" value="0" title="禁用">
      </div>
    </div>
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn" lay-submit lay-filter="formAdd">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  </form>
</div>
  <script src="/static/layui/layui.js"></script>
  <script>
    //Demo
    layui.use('form', function(){
      var form = layui.form,$ = layui.jquery;
      form.on('submit(formAdd)',function(data){
          $.post('/admin/menu/save',data.field,function(res){
               
                if(res.code ==1 ){
                  let index =  parent.layer.getFrameIndex(window.name);
                  parent.layer.close(index);
                  parent.$.pjax.reload('#main',{fragment: '#main'});
                }

                return layer.msg(res.msg,{icon:2});
          });
          
          return false;
      });
    });
    </script>
</body>
</html>